# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=cl-ppcre
pkgver=2.1.1.r3.gb4056c5
pkgrel=1
pkgdesc='Perl-compatible portable regexp library for Common Lisp'
arch=('any')
url='https://edicl.github.io/cl-ppcre/'
license=('BSD')
depends=('common-lisp' 'cl-asdf' 'cl-unicode')
makedepends=('git' 'sbcl')
_commit='b4056c5aecd9304e80abced0ef9c89cd66ecfb5e'
source=("$pkgname::git+https://github.com/edicl/cl-ppcre#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
}

package() {
  cd "$pkgname"

  # create directories
  install -vd \
    "$pkgdir/usr/share/common-lisp/source/$pkgname" \
    "$pkgdir/usr/share/common-lisp/systems"

  # library
  cp -vr test cl-ppcre-unicode ./*.{lisp,asd} "$pkgname.asd" "$pkgdir/usr/share/common-lisp/source/$pkgname"

  pushd "$pkgdir/usr/share/common-lisp/systems"
  ln -s "../source/$pkgname/$pkgname.asd" .
  ln -s "../source/$pkgname/$pkgname-unicode.asd" .
  popd

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md docs/index.html

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
